﻿
-- 新增监视点信息（区域门信息）
create procedure [dbo].[JsdInfo_Add]
@Jsdm varchar(50),
@Bz varchar(400),
@Lx smallint, -- 0:区域 1:门
@Jsdfbh varchar(18) = null
as
declare
@Jsdbh varchar(18) -- 形如：0001
if(@Jsdfbh is null)
begin
set @Jsdbh='01'
end
else
begin
select 
@Jsdbh =case when max(Jsdbh) is NULL then @Jsdfbh+'01' else @Jsdfbh+right('00'+cast(cast(right(max(Jsdbh),len(@Jsdfbh)+1) as smallint)+1 as varchar),2) end 
from Jsd_Info where Jsdfbh=@Jsdfbh
end
insert into Jsd_Info values(@Jsdbh,@Jsdfbh,@Jsdm,@Bz,@Lx)